<!DOCTYPE html>
<html lang="zh-cn">
<head>
{include file="public/header" /}
</head>
<body>
<div class="panel admin-panel">
<div class="panel-head"><strong class="icon-menu"> 文章列表</strong></div>
<div class="padding border-bottom">
  <ul class="search" style="padding-left:10px;">
    <li> <a class="button border-main icon-tianjia" href="javascript:;" onclick="openifram('文章添加','100%','100%','{:url('Thumbpic/add')}')"> 文章添加</a> </li>
    <li><button type="button"  class="button border-green" id="checkall"><span class="icon-xuanze"></span> 全选</button></li>
    <li><button type="submit" class="button border-red" onclick="delall()" id="checkdel"><span class="icon-shanchu"></span> 批量删除</button></li>
    
    <form action="{:url('content/lst')}" method="POST">
      <li>
        <select name="cid" class="input w50" id="options" style="width: 100%;">
            <option value="0">请选择分类</option>
            {volist name="Thumbpic" id="vo"}
            <option value="{$vo.id}">{$vo.name_display}</option>
            {/volist}
        </select>
      </li>
      <li>
      <input type="text" placeholder="请输入搜索关键字" name="keywords" class="input" />
      </li>
      <li><button type="submit" class="button border-main" id="checkdel"><span class="icon-sousuo"></span> 搜索</button></li>
    </form>
  </ul>
</div>
<form method="post" action="" id="listform">
    <table class="table table-hover text-center">
      <tr>
        <th width="100" style="text-align:left; padding-left:20px;">ID</th>
        <th>图片</th>
        <th>名称</th>
        <th>作者</th>
        <th>所属栏目</th>
        <th>标签</th>
        <th width="10%">更新时间</th>
        <th width="310">操作</th>
      </tr>
      {volist name="thumb" id="vo"}
        <tr>
          <td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="{$vo.id}" />{$vo.id}</td>
          <td width="10%"><img src="{$vo.thumb}" alt="" width="100" height="" /></td>
          <td>{$vo.title}</td>
          <td><font color="#00CC99">{$vo.author}</font></td>
          <td>{$vo['cateid']|catname}</td>
          <td><font color="#00CC99">{$vo.tag}</font></td>
          <td>{$vo['newtime']|date='Y-m-d',###}</td>
          <td><div class="button-group"> <a class="button border-main" href="javascript:;" onclick="openifram('修改内容','100%','100%','{:url('Thumbpic/edit',['id'=>$vo.id])}')"><span class="icon-xiugai"></span> 修改</a> <a class="button border-red" href="javascript:void(0)" onclick="system_category_del(this,{$vo.id})"><span class="icon-shanchu"></span> 删除</a> </div></td>
        </tr>
        {/volist}
    </table>
  </div>
  {$thumb->render()}
</form>
<script type="text/javascript">

// 全选
jQuery(function($){
  //全选 
  $("#checkall").click(function(){ 
      $("input[name='id[]']").attr("checked","true"); 
      // $("input[name='checkbox']:checkbox:checked").each(function(){ 
      //     aa.push($(this).val());
      // })
      // console.log(aa);
      // aa= new Array();
  })
})
function delall(){
  layer.confirm('是否全部删除',function(){
    var ids= new Array(); 
    $("input[name='id[]']:checkbox:checked").each(function(){ 
      ids.push($(this).val());
    });
    var idj=ids.join(",")
    // alert(idj);
    $.ajax({
      type:"GET",
      url:"{:url('Thumbpic/delall')}",
      data:{
        'id':idj,
      },
      success:function(data){
        var data=eval("("+data+")");
        if (data.status) {
          parent.layer.msg('删除成功~！',{icon:1,time:1000,},function(){parent.location.reload();});
        }else{
          parent.layer.msg('删除失败~！',{icon:2,time:1000,},function(){parent.location.reload();});
        }
      }
    })
  });
}

// 单个删除
function system_category_del(obj, id) {

  layer.confirm('确认要删除吗？', function (index) {

    $.ajax({
        type: "POST",
        url: "{:url('Thumbpic/del')}",
        data: {
        'id':id,
        },
        dataType: "json",
        success: function(data){
          var data=eval("("+data+")");

        if (data.status == 1){

          parent.layer.msg('删除成功~！',{icon:1,time:1000,},function(){parent.location.reload();});
        
        }
        else{
        parent.layer.msg('删除失败~！',{icon:2,time:1000,},function(){parent.location.reload();});
        }
        }
      });
    });
}
function openifram(title,width,height,url){
    var index=layer.open({
      type: 2,
      title: title,
      fixed:false,
      area: [width, height],
      shade: [0.2, '#393D49'],
      maxmin: true,
      content: url,
  });
  layer.full(index);//弹出就是全屏

}
</script>
</body>
</html>